import React, { Component } from 'react';
import {
	StyleSheet, Image
} from "react-native";
import { GLOBAL } from '../../../config/global';
import { style } from '../../../theme/style';

const scale = GLOBAL.SCALE;

//inoutFlag：1入库0 出库
const requestObj = {
	pageNo: 1,
	pageSize: 10,
	status: '',
	inoutFlag: 1,
};

export class NoticeListPage extends Component {
	static navigationOptions = {
		// headerTitle: '通知单',
		headerTintColor: style.color.white,
		headerRight: (<Image style={{ marginLeft: 18 * scale, width: 9 * scale, height: 16 * scale }} source={require('../../../imgs/goBackEmpty.png')} />),
		headerStyle: {
			elevation: 0,
			backgroundColor: style.color.themeColor,
		},
		headerTitleStyle: {
			flex: 1,
			textAlign: 'center'
		}
	};

	constructor(props) {
		super(props);
		this.state = {
			loaded: false,
			emptyResult: false,
			dataSource: [],
			showFoot: 0, // 控制foot， 0：隐藏footer  1：已加载完成,没有更多数据   2 ：显示加载中
		}
		this.sendData = {
			companyId: this.companyId
		}
		this._setKeyWord = this._setKeyWord.bind(this);
		this._doSearch = this._doSearch.bind(this);
	}

	componentDidMount () {
		requestObj.companyName = '';
		this.props.navigation.setParams({
			doSearch: this._doSearch,
			setKeyWord: this._setKeyWord
		});
	}

	async _doSearch () {
		if (requestObj.companyName && requestObj.companyName.length) {
			this.setState({
				loaded: true,
				dataSource: [],
				emptyResult: false,
			});
			this._fetchCustomerAsync(1);
		} else {
			Alert.alert('请填写搜索条件');
		}

	}
	/**
 * 设置搜索关键字
 * @param {String} txt 
 */
	_setKeyWord (txt) {
		requestObj.companyName = txt;
		console.log(requestObj.companyName);
	}

}

const styles = StyleSheet.create({
	searchView: {
		paddingLeft: 5 * scale,
		alignItems: 'center',
		flex: 1,
		flexDirection: 'row',
		width: 300 * scale,
		height: 31 * scale,
		backgroundColor: '#F6F6F6',
		borderRadius: 4,
	},
	searchInput: {
		padding: 0,
		flex: 1,
		height: 31 * scale,
		fontSize: 12 * scale,
		color: '#979797',
		marginLeft: 3 * scale,
	},
	searchLeftIcon: {
		height: 13 * scale,
		width: 13 * scale,
		marginLeft: 10 * scale,
		marginRight: 10 * scale,
	},
	searchRightIcon: {
		height: 10 * scale,
		width: 10 * scale,
		marginRight: 10 * scale,
	},
	flatList: {
	},
	footer: {
		flexDirection: 'row',
		height: 24,
		justifyContent: 'center',
		alignItems: 'center',
		marginBottom: 10,
	},
	noMoreText: {
		color: '#999999',
		fontSize: 14 * scale,
		marginTop: 5 * scale,
		marginBottom: 5 * scale,
	},
	container: {
		flex: 1,
		backgroundColor: '#fff',
	},
})